------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  ex05 NFL24 Answers.log
  log type:  text
 opened on:  18 Feb 2026, 08:18:08

. 
. clear all

. cd "C:\Users\Jeremy Bentham\Desktop\3370S26\wk05 mle I intro\exercise answers"
C:\Users\Jeremy Bentham\Desktop\3370S26\wk05 mle I intro\exercise answers

. 
. import excel "nfl_01_24.xlsx", sheet("games") firstrow

. keep if season == 2024
(6,188 observations deleted)

. save "nfl 2024 games.dta", replace
file nfl 2024 games.dta saved

. 
. use "nfl 2024 games.dta", clear

. keep home

. duplicates drop

Duplicates in terms of all variables

(253 observations deleted)

. sort home

. gen idhome = _n

. save "nfl teams 2024.dta",  replace
file nfl teams 2024.dta saved

. 
. merge 1:m home using "nfl 2024 games.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                               285  (_merge==3)
    -----------------------------------------

. drop _merge

. save "nfl 2024 games.dta", replace
file nfl 2024 games.dta saved

. 
. use "nfl teams 2024.dta",  clear

. rename (home idhome) (away idaway)

. merge 1:m away using "nfl 2024 games.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                               285  (_merge==3)
    -----------------------------------------

. drop _merge

. save "nfl 2024 games.dta", replace
file nfl 2024 games.dta saved

. 
. use "nfl 2024 games.dta", clear

. 
. tab location, missing

   location |      Freq.     Percent        Cum.
------------+-----------------------------------
       Home |        278       97.54       97.54
    Neutral |          7        2.46      100.00
------------+-----------------------------------
      Total |        285      100.00

. 
. drop if location=="Neutral"
(7 observations deleted)

. gen hptsdiff = h_score-a_score

. gen hwins = (h_score>a_score)

. 
. drop if hptsdiff == 0
(0 observations deleted)

. 
. save "nfl 2024 games.dta", replace
file nfl 2024 games.dta saved

. 
. use "nfl teams 2024.dta",  clear

. rename (home idhome) (team idteam)

. save "nfl teams 2024.dta",  replace
file nfl teams 2024.dta saved

. 
. use "nfl 2024 games.dta", clear

. 
. forvalues i=1/32 {
  2.    gen x`i'=0
  3.    replace x`i' = 1 if idhome==`i'
  4.    replace x`i' = -1 if idaway==`i'
  5.    }
(9 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(9 real changes made)
(10 real changes made)
(10 real changes made)
(10 real changes made)
(8 real changes made)
(8 real changes made)
(8 real changes made)
(8 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(9 real changes made)
(9 real changes made)
(8 real changes made)
(8 real changes made)
(10 real changes made)
(10 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(9 real changes made)
(10 real changes made)
(8 real changes made)
(9 real changes made)
(7 real changes made)
(8 real changes made)
(10 real changes made)
(9 real changes made)
(9 real changes made)
(9 real changes made)
(8 real changes made)
(10 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(8 real changes made)
(8 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(9 real changes made)
(7 real changes made)
(8 real changes made)
(8 real changes made)
(11 real changes made)
(8 real changes made)
(8 real changes made)
(10 real changes made)
(9 real changes made)
(8 real changes made)
(9 real changes made)
(8 real changes made)
(10 real changes made)
(8 real changes made)
(8 real changes made)
(9 real changes made)
(9 real changes made)
(11 real changes made)

. 
. save "nfl 2024 games v2.dta", replace
file nfl 2024 games v2.dta saved

. 
. ***LPM
. 
. use "nfl 2024 games v2.dta", clear

. 
. reg hwins x1-x31

      Source |       SS           df       MS      Number of obs   =       278
-------------+----------------------------------   F(31, 246)      =      4.30
       Model |  24.2806446        31    .7832466   Prob > F        =    0.0000
    Residual |  44.8596432       246  .182356273   R-squared       =    0.3512
-------------+----------------------------------   Adj R-squared   =    0.2694
       Total |  69.1402878       277  .249603927   Root MSE        =    .42703

------------------------------------------------------------------------------
       hwins |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |  -.2030253   .1464578    -1.39   0.167    -.4914966     .085446
          x2 |  -.2137042   .1397672    -1.53   0.128    -.4889972    .0615887
          x3 |   .0309247   .1370632     0.23   0.822    -.2390423    .3008917
          x4 |   .0423685   .1441915     0.29   0.769    -.2416388    .3263759
          x5 |  -.4292147    .142085    -3.02   0.003    -.7090731   -.1493564
          x6 |  -.3822824   .1484647    -2.57   0.011    -.6747065   -.0898582
          x7 |  -.1841597   .1403025    -1.31   0.191    -.4605071    .0921876
          x8 |  -.4884656   .1405102    -3.48   0.001    -.7652221   -.2117092
          x9 |  -.2571484    .134406    -1.91   0.057    -.5218818     .007585
         x10 |  -.1310877   .1438786    -0.91   0.363    -.4144787    .1523033
         x11 |    .156088   .1431807     1.09   0.277    -.1259286    .4381045
         x12 |  -.0314632   .1491924    -0.21   0.833    -.3253206    .2623942
         x13 |  -.1260142   .1450708    -0.87   0.386    -.4117536    .1597251
         x14 |  -.2842969   .1495134    -1.90   0.058    -.5787866    .0101929
         x15 |   -.508358    .154259    -3.30   0.001     -.812195   -.2045211
         x16 |   .1961233   .1422478     1.38   0.169    -.0840557    .4763022
         x17 |  -.1192017   .1463314    -0.81   0.416    -.4074239    .1690206
         x18 |  -.1087373   .1435007    -0.76   0.449    -.3913839    .1739094
         x19 |  -.4372135   .1458853    -3.00   0.003     -.724557   -.1498699
         x20 |  -.3144505   .1510695    -2.08   0.038    -.6120052   -.0168959
         x21 |   .1035957   .1514841     0.68   0.495    -.1947755    .4019669
         x22 |  -.4841005   .1532223    -3.16   0.002    -.7858955   -.1823055
         x23 |  -.3984498   .1397384    -2.85   0.005    -.6736861   -.1232135
         x24 |  -.4454476   .1368503    -3.25   0.001    -.7149953   -.1758998
         x25 |  -.4333109   .1535154    -2.82   0.005    -.7356832   -.1309386
         x26 |   .1207941   .1283407     0.94   0.348    -.1319927    .3735809
         x27 |  -.1215203   .1388394    -0.88   0.382    -.3949859    .1519453
         x28 |  -.1110404   .1494181    -0.74   0.458    -.4053424    .1832616
         x29 |  -.2899342   .1492505    -1.94   0.053    -.5839061    .0040377
         x30 |  -.1281954   .1343481    -0.95   0.341    -.3928146    .1364239
         x31 |  -.5261306   .1465696    -3.59   0.000     -.814822   -.2374393
       _cons |   .5295702   .0257949    20.53   0.000     .4787631    .5803773
------------------------------------------------------------------------------

. 
. mat bb = e(b)'

. 
. svmat double bb, name(betas)

. 
. replace betas = 0 if _n==32
(1 real change made)

. 
. gen idteam = _n

. 
. drop if _n > 32
(246 observations deleted)

. 
. keep idteam betas

. 
. merge 1:1 idteam using "nfl teams 2024.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                                32  (_merge==3)
    -----------------------------------------

. 
. drop _merge

. 
. gsort -betas1

. 
. *LPM Rankings/Ratings
. 
. list

     +----------------------------+
     |     betas1   idteam   team |
     |----------------------------|
  1. |  .19612327       16     KC |
  2. |  .15608796       11    DET |
  3. |  .12079409       26    PHI |
  4. |  .10359572       21    MIN |
  5. |  .04236854        4    BUF |
     |----------------------------|
  6. |  .03092468        3    BAL |
  7. |          0       32    WAS |
  8. | -.03146324       12     GB |
  9. | -.10873729       18    LAC |
 10. | -.11104043       28    SEA |
     |----------------------------|
 11. | -.11920168       17     LA |
 12. |  -.1215203       27    PIT |
 13. | -.12601424       13    HOU |
 14. | -.12819536       30     TB |
 15. | -.13108774       10    DEN |
     |----------------------------|
 16. | -.18415972        7    CIN |
 17. |  -.2030253        1    ARI |
 18. | -.21370424        2    ATL |
 19. | -.25714839        9    DAL |
 20. | -.28429686       14    IND |
     |----------------------------|
 21. | -.28993417       29     SF |
 22. | -.31445055       20    MIA |
 23. | -.38228235        6    CHI |
 24. | -.39844979       23     NO |
 25. | -.42921473        5    CAR |
     |----------------------------|
 26. |  -.4333109       25    NYJ |
 27. | -.43721345       19     LV |
 28. | -.44544756       24    NYG |
 29. | -.48410053       22     NE |
 30. | -.48846564        8    CLE |
     |----------------------------|
 31. | -.50835805       15    JAX |
 32. | -.52613062       31    TEN |
     +----------------------------+

. 
. ***PtsDiff
. 
. use "nfl 2024 games v2.dta", clear

. 
. reg hptsdiff x1-x31

      Source |       SS           df       MS      Number of obs   =       278
-------------+----------------------------------   F(31, 246)      =      4.76
       Model |  21918.5222        31  707.049105   Prob > F        =    0.0000
    Residual |  36523.2475       246  148.468486   R-squared       =    0.3750
-------------+----------------------------------   Adj R-squared   =    0.2963
       Total |  58441.7698       277  210.981118   Root MSE        =    12.185

------------------------------------------------------------------------------
    hptsdiff |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |  -2.219248   4.178971    -0.53   0.596    -10.45038     6.01188
          x2 |  -6.550173   3.988062    -1.64   0.102    -14.40528    1.304931
          x3 |   5.879684   3.910907     1.50   0.134    -1.823451    13.58282
          x4 |   4.817042   4.114304     1.17   0.243    -3.286714     12.9208
          x5 |  -15.66059   4.054199    -3.86   0.000    -23.64596   -7.675221
          x6 |  -7.346605   4.236235    -1.73   0.084    -15.69052    .9973138
          x7 |  -2.754309   4.003336    -0.69   0.492     -10.6395    5.130879
          x8 |  -13.41375   4.009263    -3.35   0.001    -21.31061    -5.51689
          x9 |  -10.34078    3.83509    -2.70   0.007    -17.89459   -2.786983
         x10 |   .8323571   4.105375     0.20   0.839    -7.253812    8.918527
         x11 |   8.131824   4.085464     1.99   0.048     .0848723    16.17877
         x12 |   3.419911   4.256998     0.80   0.423    -4.964902    11.80473
         x13 |  -3.774189   4.139395    -0.91   0.363    -11.92737    4.378987
         x14 |  -7.843104   4.266159    -1.84   0.067    -16.24596    .5597536
         x15 |  -11.65926   4.401568    -2.65   0.009    -20.32882    -2.98969
         x16 |   .1670939   4.058844     0.04   0.967    -7.827424    8.161612
         x17 |  -3.972374   4.175364    -0.95   0.342     -12.1964    4.251648
         x18 |  -.3774127   4.094592    -0.09   0.927    -8.442343    7.687518
         x19 |  -10.95242   4.162634    -2.63   0.009    -19.15137   -2.753476
         x20 |  -7.008899   4.310558    -1.63   0.105    -15.49921     1.48141
         x21 |   2.105938   4.322388     0.49   0.627    -6.407671    10.61955
         x22 |  -11.43899   4.371987    -2.62   0.009    -20.05029   -2.827692
         x23 |   -8.48111   3.987242    -2.13   0.034     -16.3346   -.6276228
         x24 |  -11.74439   3.904834    -3.01   0.003    -19.43556   -4.053215
         x25 |  -8.700208    4.38035    -1.99   0.048    -17.32798   -.0724339
         x26 |   5.126884   3.662024     1.40   0.163    -2.086038    12.33981
         x27 |   -2.35329   3.961589    -0.59   0.553    -10.15625     5.44967
         x28 |  -3.031048   4.263439    -0.71   0.478    -11.42855    5.366452
         x29 |  -5.401191   4.258657    -1.27   0.206    -13.78927    2.986889
         x30 |   1.678772   3.833436     0.44   0.662    -5.871771    9.229314
         x31 |  -12.52028   4.182159    -2.99   0.003    -20.75769   -4.282875
       _cons |   1.860001   .7360226     2.53   0.012     .4102909    3.309711
------------------------------------------------------------------------------

. 
. mat bb = e(b)'

. 
. svmat double bb, name(betas)

. 
. replace betas = 0 if _n==32
(1 real change made)

. 
. gen idteam = _n

. 
. drop if _n > 32
(246 observations deleted)

. 
. keep idteam betas

. 
. merge 1:1 idteam using "nfl teams 2024.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                                32  (_merge==3)
    -----------------------------------------

. 
. drop _merge

. 
. gsort -betas1

. 
. *PtsDiff Rankings/Ratings
. 
. list

     +----------------------------+
     |     betas1   idteam   team |
     |----------------------------|
  1. |  8.1318235       11    DET |
  2. |  5.8796843        3    BAL |
  3. |  5.1268838       26    PHI |
  4. |  4.8170422        4    BUF |
  5. |  3.4199114       12     GB |
     |----------------------------|
  6. |  2.1059379       21    MIN |
  7. |  1.6787717       30     TB |
  8. |  .83235709       10    DEN |
  9. |  .16709386       16     KC |
 10. |          0       32    WAS |
     |----------------------------|
 11. | -.37741272       18    LAC |
 12. | -2.2192484        1    ARI |
 13. | -2.3532902       27    PIT |
 14. | -2.7543091        7    CIN |
 15. | -3.0310483       28    SEA |
     |----------------------------|
 16. | -3.7741894       13    HOU |
 17. |  -3.972374       17     LA |
 18. | -5.4011912       29     SF |
 19. | -6.5501728        2    ATL |
 20. | -7.0088985       20    MIA |
     |----------------------------|
 21. | -7.3466048        6    CHI |
 22. | -7.8431038       14    IND |
 23. | -8.4811103       23     NO |
 24. | -8.7002079       25    NYJ |
 25. | -10.340784        9    DAL |
     |----------------------------|
 26. | -10.952425       19     LV |
 27. | -11.438993       22     NE |
 28. | -11.659256       15    JAX |
 29. | -11.744387       24    NYG |
 30. | -12.520283       31    TEN |
     |----------------------------|
 31. | -13.413751        8    CLE |
 32. | -15.660592        5    CAR |
     +----------------------------+

. 
. ***Logit
. 
. use "nfl 2024 games v2.dta", clear

. 
. logit hwins x1-x31

Iteration 0:   log likelihood = -191.97487  
Iteration 1:   log likelihood = -134.39491  
Iteration 2:   log likelihood = -133.96004  
Iteration 3:   log likelihood = -133.95825  
Iteration 4:   log likelihood = -133.95825  

Logistic regression                             Number of obs     =        278
                                                LR chi2(31)       =     116.03
                                                Prob > chi2       =     0.0000
Log likelihood = -133.95825                     Pseudo R2         =     0.3022

------------------------------------------------------------------------------
       hwins |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |  -1.135068   .8390013    -1.35   0.176     -2.77948    .5093441
          x2 |  -1.247096    .808595    -1.54   0.123    -2.831913    .3377208
          x3 |   .0904812    .788693     0.11   0.909    -1.455329    1.636291
          x4 |   .3178664   .8899264     0.36   0.721    -1.426357     2.06209
          x5 |  -2.368757     .86138    -2.75   0.006    -4.057031   -.6804832
          x6 |  -2.204401   .9340737    -2.36   0.018    -4.035152   -.3736503
          x7 |   -1.10022   .8155261    -1.35   0.177    -2.698621    .4981821
          x8 |  -2.931097   .9267982    -3.16   0.002    -4.747588   -1.114605
          x9 |  -1.446508    .782459    -1.85   0.065    -2.980099    .0870837
         x10 |  -.8149291   .8321755    -0.98   0.327    -2.445963    .8161048
         x11 |    .925321   .9199366     1.01   0.314    -.8777216    2.728364
         x12 |  -.2149692   .9037422    -0.24   0.812    -1.986271    1.556333
         x13 |  -.7819796   .8767111    -0.89   0.372    -2.500302    .9363426
         x14 |  -1.730618    .886247    -1.95   0.051     -3.46763    .0063942
         x15 |  -3.202317   1.009543    -3.17   0.002    -5.180984   -1.223649
         x16 |   1.271291    1.00406     1.27   0.205    -.6966303    3.239212
         x17 |  -.7196775   .8522299    -0.84   0.398    -2.390017    .9506625
         x18 |  -.7080838   .8332122    -0.85   0.395     -2.34115     .924982
         x19 |  -2.550972   .9026982    -2.83   0.005    -4.320228   -.7817162
         x20 |  -1.843692    .881849    -2.09   0.037    -3.572085   -.1153001
         x21 |   .6287026    .989485     0.64   0.525    -1.310652    2.568058
         x22 |  -2.648345   .9197117    -2.88   0.004    -4.450947   -.8457434
         x23 |  -2.241789   .8454455    -2.65   0.008    -3.898832   -.5847462
         x24 |  -2.562208   .8988349    -2.85   0.004    -4.323893   -.8005244
         x25 |  -2.405997    .907166    -2.65   0.008     -4.18401   -.6279846
         x26 |   .7292884   .7929564     0.92   0.358    -.8248776    2.283454
         x27 |  -.7416965   .7987674    -0.93   0.353    -2.307252    .8238588
         x28 |  -.7143905   .8586391    -0.83   0.405    -2.397292    .9685112
         x29 |  -1.582814   .8726787    -1.81   0.070    -3.293233    .1276046
         x30 |  -.7903403   .7640142    -1.03   0.301    -2.287781       .7071
         x31 |  -3.230382   .9905844    -3.26   0.001    -5.171892   -1.288872
       _cons |   .1831832   .1535841     1.19   0.233    -.1178362    .4842025
------------------------------------------------------------------------------

. 
. mat bb = e(b)'

. 
. svmat double bb, name(betas)

. 
. replace betas = 0 if _n==32
(1 real change made)

. 
. gen idteam = _n

. 
. drop if _n > 32
(246 observations deleted)

. 
. keep idteam betas

. 
. merge 1:1 idteam using "nfl teams 2024.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                                32  (_merge==3)
    -----------------------------------------

. 
. drop _merge

. 
. gsort -betas1

. 
. *Logit Rankings/Ratings
. 
. list

     +----------------------------+
     |     betas1   idteam   team |
     |----------------------------|
  1. |  1.2712907       16     KC |
  2. |  .92532097       11    DET |
  3. |  .72928837       26    PHI |
  4. |  .62870263       21    MIN |
  5. |  .31786639        4    BUF |
     |----------------------------|
  6. |  .09048118        3    BAL |
  7. |          0       32    WAS |
  8. | -.21496924       12     GB |
  9. | -.70808378       18    LAC |
 10. | -.71439047       28    SEA |
     |----------------------------|
 11. | -.71967748       17     LA |
 12. | -.74169646       27    PIT |
 13. | -.78197963       13    HOU |
 14. |  -.7903403       30     TB |
 15. | -.81492914       10    DEN |
     |----------------------------|
 16. | -1.1002197        7    CIN |
 17. | -1.1350681        1    ARI |
 18. | -1.2470963        2    ATL |
 19. | -1.4465077        9    DAL |
 20. | -1.5828141       29     SF |
     |----------------------------|
 21. |  -1.730618       14    IND |
 22. | -1.8436924       20    MIA |
 23. |  -2.204401        6    CHI |
 24. | -2.2417889       23     NO |
 25. |  -2.368757        5    CAR |
     |----------------------------|
 26. | -2.4059973       25    NYJ |
 27. | -2.5509722       19     LV |
 28. | -2.5622085       24    NYG |
 29. | -2.6483452       22     NE |
 30. | -2.9310965        8    CLE |
     |----------------------------|
 31. | -3.2023169       15    JAX |
 32. | -3.2303819       31    TEN |
     +----------------------------+

. 
. log close
      name:  <unnamed>
       log:  ex05 NFL24 Answers.log
  log type:  text
 closed on:  18 Feb 2026, 08:18:11
------------------------------------------------------------------------------------------------------------------
